
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@page import="com.tss.util.*"%>
<%@page import="com.jedi.*"%>
<%@page import="java.sql.Date"%>
<%@page import="com.store.*"%>
<%@page import="com.store.Contract"%>
<%@page import="java.util.*"%>
<%@include file="../global_var.jsp"%>
<%@include file="../check_login.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
User just_user = (User)session.getAttribute("LoginUser");
String power_enable_id = "10101";
if (!just_user.hasPower(power_enable_id)) {
	out.println(strNoPowerInfo); 
	return;
}


%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    
<title>My JSP 'techcontract_add.jsp' starting page</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <link href="style/main.css" rel="stylesheet" type="text/css">
	<script language="javascript" src="js/common.js"></script>
<%
 String strErr = "";
 FormatDate formatDate= new FormatDate();
 String prjname          = ParamUtils.getParameter(request,"prjname","");
 Date nowdate=formatDate.toDate(TSSDate.shortDate());
String conid       = ParamUtils.getParameter(request,"conid","");
String serviceid        = ParamUtils.getParameter(request,"serviceid","");
String area           = ParamUtils.getParameter(request,"area","");
String customer     = ParamUtils.getParameter(request,"customer","");
String linkman          = ParamUtils.getParameter(request,"linkman","");
String phone             = ParamUtils.getParameter(request,"phone","");
String saleid          = ParamUtils.getParameter(request,"saleid","0");
String status            = ParamUtils.getParameter(request,"status","");
String begindate        = ParamUtils.getParameter(request,"begindate",TSSDate.shortDate());
String enddate          = ParamUtils.getParameter(request,"enddate",TSSDate.shortDate());
int servicelevel     = ParamUtils.getIntParameter(request,"servicelevel",0);

String contractdesc     = ParamUtils.getParameter(request,"contractdesc","");
String contractfile       = ParamUtils.getParameter(request,"contractfile","");
Date techbegindate    = ParamUtils.getDateParameter(request,"techbegindate",nowdate);//日期
String techenddate    = ParamUtils.getParameter(request,"techenddate",TSSDate.shortDate());
String sevbegindate    = ParamUtils.getParameter(request,"sevbegindate",TSSDate.shortDate());
String sevenddate    = ParamUtils.getParameter(request,"sevenddate",TSSDate.shortDate());
String analyreport          = ParamUtils.getParameter(request,"analyreport","");
String techsupport        = ParamUtils.getParameter(request,"techsupport","");
int comid          = ParamUtils.getIntParameter(request,"comid",0);
String techmanager        = ParamUtils.getParameter(request,"techmanager","0");
String assigntime          = ParamUtils.getParameter(request,"assigntime","");
String fifee   = ParamUtils.getParameter(request,"fifee","0.00");//-- 初次安装费
String  mfee =ParamUtils.getParameter(request,"mfee","0.00");//-- (1-3年)现场维护
String myear= ParamUtils.getParameter(request,"myear","0");// -- 现场维护年限
String spartfee= ParamUtils.getParameter(request,"spartfee","0.00");// -- 备件成本
String outefee= ParamUtils.getParameter(request,"outefee","0.00");//-- 外部人员技术成本
String signfee= ParamUtils.getParameter(request,"signfee","0.00");
 String cmd = ParamUtils.getParameter(request,"cmd","");
UserMgr userMgr = new UserMgr();

if (cmd.trim().equals("insert")) {
	if (strErr.trim().equals("") && area.trim().equals("")) {
		strErr = "请选择区域!";
	}
	if (strErr.trim().equals("") && prjname.trim().equals("")) {
		strErr = "请输入项目名称!";
	}

	if (strErr.trim().equals("") && customer.trim().equals("")) {
		strErr = "请输入客户名称!";
	}
	
	if (strErr.trim().equals("") && comid==0) {
		strErr = "请选择厂商!";
		
	}
	if (strErr.trim().equals("") && techmanager.trim().equals("0")) {
		strErr = "请选择项目经理!";
		
	}
	if (strErr.trim().equals("") && contractdesc.length() >= 500) {
		strErr = "合同描述信息在500字以内!";
	}
	
if (strErr.trim().equals("")) {
		try {
			Float.parseFloat(fifee);
		}
		catch(Exception ex) {
			strErr = "初次安装费金额数值输入错误!";
		}
	}
	if (strErr.trim().equals("")) {
		try {
			Float.parseFloat(mfee);
		}
		catch(Exception ex) {
			strErr = "现场维护金额数值输入错误!";
		}
	}
	if (strErr.trim().equals("")) {
		try {
			Float.parseFloat(myear);
		}
		catch(Exception ex) {
			strErr = "维护年限应为整型!";
		}
	}
		if (strErr.trim().equals("")) {
		try {
			Float.parseFloat(signfee);
		}
		catch(Exception ex) {
			strErr = "签约金额数值输入错误!";
		}
	}
	
	if (strErr.trim().equals("")) {
		try {
			Float.parseFloat(spartfee);
		}
		catch(Exception ex) {
			strErr = "备件成本数值输入错误!";
		}
	}
	if (strErr.trim().equals("")) {
		try {
			Float.parseFloat(outefee);
		}
		catch(Exception ex) {
			strErr = "外部人员技术成本金额数值输入错误!";
		}
	}

	
	if (strErr.trim().equals("")) {
	
		Contract contract = new Contract();
		contract.setArea(area);
		
		contract.setBegindate(formatDate.toDate(begindate));
		contract.setContractdesc(contractdesc);
		contract.setContractlile(contractfile);
		contract.setCustomer(customer);
		contract.setEnddate(formatDate.toDate(enddate));
		contract.setLinkman(linkman);
		contract.setPhone(phone);
		contract.setSaleid(saleid);
		contract.setServiceid(serviceid);
		contract.setSevbegindate(formatDate.toDate(sevbegindate));
		contract.setSevenddate(formatDate.toDate(sevenddate));
		contract.setStatus(1);
		contract.setServicelevel(servicelevel);
		contract.setTechbegindate(techbegindate);
		contract.setTechenddate(formatDate.toDate(techenddate));
		contract.setAnalyreport(analyreport);
		contract.setTechsupport(techsupport);
		contract.setComid(comid);
		contract.setTechmanager(techmanager);
		contract.setAssigntime(formatDate.toDate(assigntime));
		contract.setContype(2);
		contract.setFifee(Double.parseDouble(fifee));
		contract.setMfee(Double.parseDouble(mfee));
		contract.setMyear(Integer.parseInt(myear));
		contract.setSpartfee(Double.parseDouble(spartfee));
		contract.setOutefee(Double.parseDouble(outefee));
		contract.setSignfee(Double.parseDouble(signfee));
		contract.setPrjname(prjname);
		contract.setCreateman(just_user.getId());
		contract.insert();
	if (contract.hasErr()) strErr = contract.getErrHtml();
                
	}
}
      
    
    %>
   <script language="javascript" >
   function clk_submit() {
	var oForm = document.operatorForm;
	oForm.cmd.value = "insert";
	return true;
}


	
function upload_contract() {
	var oForm = document.operatorForm;
	var ret = window.showModalDialog('../selectFrm.htm','incontract_mgt/upload_contract.jsp','dialogHeight: 200px;dialogWidth: 300px; center: yes; status:no;help: no');
	if(ret && ret != "") {
		oForm.contractfile.value = ret;
	}
}

//上传合同分析报告
function upload_analyreport() {
	var oForm = document.operatorForm;
	var ret = window.showModalDialog('../selectFrm.htm','incontract_mgt/upload_analyreport.jsp','dialogHeight: 200px;dialogWidth: 300px; center: yes; status:no;help: no');
	if(ret && ret != "") {
		oForm.analyreport.value = ret;
	}
}
//商船技术支援单
function upload_techsupport() {
	var oForm = document.operatorForm;
	var ret = window.showModalDialog('../selectFrm.htm','incontract_mgt/upload_techsupport.jsp','dialogHeight: 200px;dialogWidth: 300px; center: yes; status:no;help: no');
	if(ret && ret != "") {
		oForm.techsupport.value = ret;
	}
}
</script>
</head>

<body  leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td >
     <form name="operatorForm" method="post" onSubmit="return clk_submit();">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td height="100" align="center" valign="top" style="padding-top:10px;padding-bottom:10px;">
            <table width="98%" border="0" cellpadding="1" cellspacing="1" bgcolor="#000000">
			
			 <tr>
                <td height="24" colspan="7" bgcolor="#EDEDF0" style="padding-left:10px;">
                提示：<font color="red">*</font> 号为必填项，请您认真填写                </td>
              </tr>
               <%if (!strErr.trim().equals("")) {%>
              <tr> 
                <td height="24" colspan="7" bgcolor="#D7D7DB" style="padding-left:10px;">
                  错误提示：
                 
                  <font color=red><%=strErr%></font>                </td>
              </tr>
              <%}%>
              
              <tr> 
                <td height="24" colspan="7" bgcolor="#858585" style="padding-left:10px;">
                  <font color="#FFFFFF"><strong>合同信息</strong></font>  </td>
              </tr>
               
             <tr> 
                <td width="17%" height="24" align="right" bgcolor="#D7D7DB" >所在区域<span style="padding-right:5px;"><font color="red">*</font></span></td>
                <td bgcolor="#EDEDF0" style="padding-left:5px;">
                   <select name="area" style="width:100px">
                    <%for(int i=0;i<area_item_info.length;i++){%>
                    <option value="<%=area_item_info[i]%>"<%if (area.trim().equals(area_item_info[i])){%> selected<%}%>><%=area_item_info[i]%></option>
                    <%}%>
                  </select>                  </td>
              </tr>
              
                                 <tr>
                <td height="24" align="right" bgcolor="#D7D7DB" >项目名称<span style="padding-right:5px;"><font color="red">*</font></span></td>
                <td colspan="6" bgcolor="#EDEDF0" style="padding-left:5px;">
                <input name="prjname" type="text"    class="inputbox" value="<%=prjname%>" size="50" maxlength="100">                </td>
              </tr>
              
			  
        
              <tr>
                <td height="24" align="right" bgcolor="#D7D7DB" >客户名称<span style="padding-right:5px;"><font color="red">*</font></span></td>
                <td colspan="6" bgcolor="#EDEDF0" style="padding-left:5px;">
                <input name="customer" type="text"    class="inputbox" value="<%=customer%>" size="50" maxlength="100">                </td>
              </tr>
  					      <tr> 
                <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;"> 服务合同号：</td>
                <td colspan="6" bgcolor="#EDEDF0" style="padding-left:5px;"> 
                 <input name="serviceid" type="text" value="<%=serviceid%>" size="30" maxlength="30" class="inputbox"></td>
              </tr>
              
                 <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >客户联系人：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                   <input name="linkman" type="text" value="<%=linkman%>"  id="linkman" size="30" maxlength="30" class="inputBox"></td>
                 </tr>
                 <tr>
                   <td height="23" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >联系电话：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                   <input name="phone" type="text" value="<%=phone%>" id="phone" size="30" maxlength="30" class="inputBox">
                   </td>
                 </tr><!--
                 
                  <tr>
                    <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >合同状态：</td>
                    <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                    <select name="status" style="width:100px">
                      <option value="1" >登记</option>
                      <option value="2">执行</option>
                    </select>                    </td>
                  </tr>
                  --><tr>
                   <td height="24" align="right" bgcolor="#D7D7DB"  >厂商名称<span style="padding-right:5px;"><font color="red">*</font></span></td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                  <select  name="comid" style="display:inline" style="width:100px" >
				  <option value="0" selected>==请选择==</option>
                    <%
                  CompanyMgr comMgr = new CompanyMgr();
                 List   list =comMgr.getCompanys();
                    if (list != null && list.size() > 0) {
                    	for(int i=0;i<list.size();i++) {
                    		Company item = (Company)list.get(i);
                    %>
                    <option value="<%=item.getComid()%>" <%if (item.getComid()==comid) {%> selected<%}%>><%=item.getComnam()%></option>
                    <%
                    }
                    }
                    %>
			      </select> </td>
                 </tr>
                 <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB"  >项目经理<span style="padding-right:5px;"><font color="red">*</font></span></td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                   <select name="techmanager" id="techmanager"  style="width:100px">
            	        <option value="0">==请选择==</option>
            	        <%
            	    String manager="pm";
            	         list = userMgr.getUsersGroupbyroleid(manager);
            	        if (list != null && list.size() > 0) {
                    		for(int i=0;i<list.size();i++){
                    			User item = (User)list.get(i);
                    	%>
                        <option value="<%=item.getId()%>"<%if (item.getId().trim().equals(techmanager)) {%> selected<%}%>><%=item.getUserName()%></option>
                    	<%}}%>
            	      </select>                   </td>
                 </tr>
				 
                 <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >销售员：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                   <select name="saleid" id="saleid" style="width:100px">
            	        <option value="0">==请选择==</option>
            	        <%
            	    String saler="saler";
            	         list = userMgr.getUsersGroupbyroleid(saler);
            	        if (list != null && list.size() > 0) {
                    		for(int i=0;i<list.size();i++){
                    			User item = (User)list.get(i);
                    	%>
                        <option value="<%=item.getId()%>"<%if (item.getId().trim().equals(saleid)) {%> selected<%}%>><%=item.getUserName()%></option>
                    	<%}}%>
            	      </select>                   </td>
                 </tr>
                
                 
                 
                 <tr> 
                <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >合同有效期：</td>
                <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                
                  从 <span id="htmlbegindateTime">&nbsp;</span> &nbsp; 至 &nbsp; <span id="htmlenddateTime" >&nbsp;</span>
                        </td>
              </tr>
             
              
			  <tr>
			    <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">合同服务等级：</td>
			    <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
			    <select name="servicelevel" style="width:100px">
			       <%
            	SevgradeMgr sevgradeMgr = new SevgradeMgr();
            	         list = sevgradeMgr.getGradeGroupBy();
            	        if (list != null && list.size() > 0) {
                    		for(int i=0;i<list.size();i++){
                    			Sevgrade item = (Sevgrade)list.get(i);
                    	%>
                        <option value="<%=item.getSgid()%>"<%if (item.getSgid()==servicelevel) {%> selected<%}%>><%=item.getSgname()%></option>
                    	<%}}%>
			      </select>			    </td>
			    </tr>
			  <tr>
			    <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">合同描述：</td>
			    <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
			    <textarea name="contractdesc" cols="50" rows="4" id="contractdesc"><%=contractdesc%></textarea>			    </td>
			    </tr>
			  <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >合同分析报告：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                   <input name="analyreport" type="text" value="<%=analyreport%>" id="analyreport" size="45" maxlength="100" readonly="readonly"  style="background-color:#EDEDE8">
                   <input type="button" name="upload" onClick="upload_analyreport();" value="上传附件" class="inputButton">                   </td>
                 </tr>
                   <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >技术支援单：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                   <input name="techsupport" type="text" value="<%=techsupport%>"   id="techsupport" size="45" maxlength="100" readonly="readonly"  style="background-color:#EDEDE8">
                   <input type="button" name="upload" onClick="upload_techsupport();" value="上传附件" class="inputButton">                   </td>
                 </tr>
                <tr> 
                <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">合同附件文件：</td>
                <td colspan="6" bgcolor="#EDEDF0" style="padding-left:5px;">
                  <input name="contractfile" type="text" id="contractfile" value="<%=contractfile%>" size="45" maxlength="100" readonly="readonly"  style="background-color:#EDEDE8"> 
                   <input type="button" name="upload" onClick="upload_contract();" value="上传附件" class="inputButton"></td>
              </tr>
              <tr> 
                <td height="24" colspan="7" bgcolor="#858585" style="padding-left:10px;">
                  <font color="#FFFFFF"><strong>合同费用</strong></font>&nbsp;&nbsp;                   </td>
              </tr>
			    <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >初次安装费：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                   <input name="fifee" type="text" value="<%=fifee%>"  id="fifee" size="20"  maxlength="10" class="inputBox" style="background-color:#EDEDE8" readonly="readonly">￥</td>
                </tr>
			    <tr>
			      <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >(1-3年)现场维护：</td>
			      <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
			      <input name="mfee" type="text" id="mfee" value="<%=mfee%>" size="20" maxlength="10" class="inputBox" style="background-color:#EDEDE8" readonly="readonly">￥</td>
		        </tr>
		         
			    <tr>
			      <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >现场维护年限：</td>
			      <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
			      <input name="myear" type="text" id="myear" value="<%=myear%>" size="20" maxlength="2" class="inputBox" style="background-color:#EDEDE8" readonly="readonly">年</td>
		        </tr>
		        <tr>
			      <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >签约金额：</td>
			      <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
			      <input name="signfee" type="text" value="<%=signfee%>" size="20" maxlength="10" class="inputBox"  >￥</td>
		        </tr>
			    <tr>
			      <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >备件成本：</td>
			      <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
			      <input name="spartfee" type="text" id="spartfee" value="<%=spartfee%>" size="20" maxlength="10" class="inputBox">￥</td>
		        </tr>
			    <tr>
			      <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >外部人员技术成本：</td>
			      <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
			      <input name="outefee" type="text" id="outefee" value="<%=outefee%>" size="20" maxlength="10" class="inputBox">￥</td>
		        </tr>
		         
                <tr> 
                <td height="24" colspan="7" bgcolor="#858585" style="padding-left:10px;">
                  <font color="#FFFFFF"><strong>培训及服务时间</strong></font>&nbsp;&nbsp;                   </td>
              </tr>
                <tr>
                  <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;"><p>培训时间：</p>				 </td>
                  <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
				      从 <span id="htmltechbegindateTime">&nbsp;</span> &nbsp; 至 &nbsp; <span id="htmltechenddateTime" >&nbsp;</span>
				
				  
				  &nbsp;</td>
                </tr>
                <tr>
                  <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">专业化服务时间：</td>
                  <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
				   从 <span id="htmlsevbegindateTime">&nbsp;</span> &nbsp; 至 &nbsp; <span id="htmlsevenddateTime" >&nbsp;</span>
				 
				  
				  &nbsp;</td>
                </tr>
              
			   
              <tr> 
                <td bgcolor="#EDEDF0" colspan="7" align="center">
                  <input type="submit" name="submit" value="提 交" class="inputButton"> 
                  <input type="reset" name="reset" value="重 写" class="inputButton">    
                  <input type="hidden" name="cmd" value="">              </td>
              </tr>
            </table>
          </td>
        </tr>
       
      </table>
      </form>
    </td>
  </tr>
</table>
<script language="javascript">

htmltechbegindateTime.innerHTML = showCalenderInput("techbegindate","operatorForm","<%=techbegindate%>",1);
htmltechenddateTime.innerHTML = showCalenderInput("techenddate","operatorForm","<%=techenddate%>",1);

htmlbegindateTime.innerHTML = showCalenderInput("begindate","operatorForm","<%=begindate%>",1);
htmlenddateTime.innerHTML = showCalenderInput("enddate","operatorForm","<%=enddate%>",1);

htmlsevbegindateTime.innerHTML = showCalenderInput("sevbegindate","operatorForm","<%=sevbegindate%>",1);
htmlsevenddateTime.innerHTML = showCalenderInput("sevenddate","operatorForm","<%=sevenddate%>",1);
</script>
<script language="javascript" >
	
function clk_add_product(){
var device_line_id=1;
var pgaeUrl = "techcontract_mgt/techcontract_sel_product.jsp";
	var str = window.showModalDialog('../selectFrm.htm',pgaeUrl,'dialogHeight: 300px;dialogWidth: 400px;center:yes;dialogHide:no;status:no;help: no');
     	if(str!= null)
   	{
   		var valArray = str.split(",");
   	var	materialid =valArray[0];
   	var listPrice  =valArray[1];
   	var sn    =valArray[2];
	var begindate   =valArray[4];
	var enddate=valArray[5];
	var productid  =valArray[3];

var oRow = tableproduct.insertRow(tableproduct.rows.length);
	
	oRow.id = device_line_id;
	oRow.bgColor = "#FFFFFF";
	var oCol = oRow.insertCell(0);
	oCol.height = "22";
	oCol.innerHTML = '<input type="text" name="materialid" maxlength="50" value="' + materialid + '" class="device_list" style="background-color:#EDEDF0" readonly="readonly">';
	oCol = oRow.insertCell(1);
oCol.innerHTML = '<input type="text" name="productid" maxlength="50" value="' + productid + '" class="device_list" style="background-color:#EDEDF0" readonly="readonly">';
	oCol = oRow.insertCell(2);
	oCol.innerHTML = '<input type="text" name="listPrice" maxlength="50"align="right" value="' + listPrice + '" class="device_list"  style="background-color:#EDEDF0" readonly="readonly">';
	oCol = oRow.insertCell(3);
	oCol.innerHTML = '<input type="text" name="devicesn" maxlength="50"  value="' + sn + '" class="device_list"  style="background-color:#EDEDF0" readonly="readonly">';
	oCol = oRow.insertCell(4);
	oCol.innerHTML = '<input type="text" name="serbegindate" maxlength="50" value="'+begindate + '" class="device_list" style="background-color:#EDEDF0" readonly="readonly">';
	oCol = oRow.insertCell(5);
	oCol.align = "center";
	oCol.innerHTML = '<input type="text" name="serenddate" maxlength="50" value="'+enddate + '" class="device_list" style="background-color:#EDEDF0" readonly="readonly">';
	oCol = oRow.insertCell(6);
	oCol.align = "center";
	oCol.innerHTML = '<img src="images/dustbin_tag.gif" style="cursor:hand;" onclick="clk_del_product(\'' + device_line_id + '\');">';
	
		oCol = oRow.insertCell(7);
	oCol.align = "center";
	oCol.innerHTML = '<input type="hidden" name="contype" maxlength="50" value="1" class="device_list" style="background-color:#EDEDF0" readonly="readonly">';
	
	
	device_line_id ++;
}
}
function clk_del_product(row_id) {
	var row_num = 0;
	for(var i=0;i<tableproduct.rows.length;i++) {
		if (tableproduct.rows[i].id == row_id) {
			tableproduct.deleteRow(row_num);
			return;
		}
		row_num ++;
	}
}

function clk_add_server(){
var line_id=1;
var pgaeUrl = "techcontract_mgt/techcontract_sel_product.jsp";
	var str = window.showModalDialog('../selectFrm.htm',pgaeUrl,'dialogHeight: 300px;dialogWidth: 400px;center:yes;dialogHide:no;status:no;help: no');
     	if(str!= null)
   	{
   		var valArray = str.split(",");
   	var	materialid =valArray[0];
   	var listPrice  =valArray[1];
   	var sn    =valArray[2];
	var begindate   =valArray[4];
	var enddate=valArray[5];
	var productid  =valArray[3];

var oRow = servertable.insertRow(servertable.rows.length);
	
	oRow.id = line_id;
	oRow.bgColor = "#FFFFFF";
	var oCol = oRow.insertCell(0);
	oCol.height = "22";
	oCol.innerHTML = '<input type="text" name="materialid" maxlength="50" value="' + materialid + '" class="device_list" style="background-color:#EDEDF0" readonly="readonly">';
	oCol = oRow.insertCell(1);
oCol.innerHTML = '<input type="text" name="productid" maxlength="50" value="' + productid + '" class="device_list" style="background-color:#EDEDF0" readonly="readonly">';
	oCol = oRow.insertCell(2);
	oCol.innerHTML = '<input type="text" name="listprice" maxlength="50"align="right" value="' + listPrice + '" class="device_list"  style="background-color:#EDEDF0" readonly="readonly">';
	oCol = oRow.insertCell(3);
	oCol.innerHTML = '<input type="text" name="devicesn" maxlength="50"  value="' + sn + '" class="device_list"  style="background-color:#EDEDF0" readonly="readonly">';
	oCol = oRow.insertCell(4);
	oCol.innerHTML = '<input type="text" name="serbegindate" maxlength="50" value="'+begindate + '" class="device_list" style="background-color:#EDEDF0" readonly="readonly">';
	oCol = oRow.insertCell(5);
	oCol.align = "center";
	oCol.innerHTML = '<input type="text" name="serenddate" maxlength="50" value="'+enddate + '" class="device_list" style="background-color:#EDEDF0" readonly="readonly">';
	oCol = oRow.insertCell(6);
	oCol.align = "center";
	oCol.innerHTML = '<img src="images/dustbin_tag.gif" style="cursor:hand;" onclick="clk_del_tableserver(\'' + line_id + '\');">';
		oCol = oRow.insertCell(7);
	oCol.align = "center";
	oCol.innerHTML = '<input type="hidden" name="contype" maxlength="50" value="2" class="device_list" style="background-color:#EDEDF0" readonly="readonly">';
	
	line_id ++;
}
}
function clk_del_tableserver(row_id) {
	var row_num = 0;
	for(var i=0;i<servertable.rows.length;i++) {
		if (servertable.rows[i].id == row_id) {
			servertable.deleteRow(row_num);
			return;
		}
		row_num ++;
	}
}
</script>
<%if (cmd.equals("insert") && strErr.trim().equals("")){%>
<script language="javascript">
alert("合同信息添加成功系统将返回首页!");
location.href="outcon_list.jsp";
</script>
<%}%>

</body>
</html>
